/*
 * @Author: xuetao 3168581151@qq.com
 * @Date: 2025-02-10
 * @LastEditors: xuetao 3168581151@qq.com
 * @LastEditTime: 2025-03-14
 * @Description: 
 */
/*
 * @Author: xuetao 3168581151@qq.com
 * @Date: 2025-02-10
 * @LastEditors: xuetao 3168581151@qq.com
 * @LastEditTime: 2025-02-26
 * @Description: 主题设置
 */
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart' show kIsWeb;

final ThemeData lightTheme = ThemeData(
  brightness: Brightness.light, // 整个应用使用明亮色调
  useMaterial3: true, // 启用 Material 3 设计规范
  // 核心配色方案
  colorScheme: ColorScheme.light(
    primary: Color(0xFFF5F5F5), // 用于主要组件
    surface: Color(0xFFF5F5F5), // 表面颜色（如卡片背景
    onSurface: Colors.black, // 表面 上的文本颜色
  ),
  // 应用栏样式
  appBarTheme: AppBarTheme(
    backgroundColor: Color(0xFFEDEDED),
    foregroundColor: Colors.black, // 文字
    centerTitle: true, // 标题居中
    elevation: 4, // AppBar 阴影
    iconTheme: IconThemeData(
      color: Color(0xFF5A6A91), //按钮
    ),
    actionsPadding: EdgeInsets.symmetric(horizontal: 20),
  ),
  // 底部导航栏
  bottomNavigationBarTheme: BottomNavigationBarThemeData(
    backgroundColor: Colors.white,
    selectedItemColor: Color(0xFF99A8F1), // 选中项
    unselectedItemColor: Colors.black, // 未选中项
    showUnselectedLabels: true, // 显示未选中的标签
    unselectedLabelStyle: TextStyle(fontWeight: FontWeight.normal), // 未选中标签样式
    type: BottomNavigationBarType.fixed,
    enableFeedback: true, // 触摸反馈
  ),
  // 文字样式系统
  textTheme: TextTheme(
    displayLarge: TextStyle(
      fontSize: 36,
      fontWeight: FontWeight.bold,
      color: Colors.white,
    ),
    headlineLarge: TextStyle(
      fontSize: 28,
      fontWeight: FontWeight.bold,
      color: Colors.black,
    ),
    titleLarge: TextStyle(
      fontSize: 24,
      fontWeight: FontWeight.w500,
      color: Colors.black,
    ),
    bodyLarge: TextStyle(
      fontSize: 18,
      fontWeight: FontWeight.normal,
      color: Colors.black87,
    ),
    bodyMedium: TextStyle(
      fontSize: 16,
      fontWeight: FontWeight.normal,
      color: Colors.black87,
    ),
    labelMedium: TextStyle(
      fontSize: 14,
      fontWeight: FontWeight.normal,
      color: Colors.black54,
    ),
  ),
  // 输入框样式
  inputDecorationTheme: InputDecorationTheme(
    // 文本类
    hintStyle: TextStyle(
      fontSize: 18,
      fontWeight: FontWeight.w500,
      color: Color(0x99000000),
    ),
    labelStyle: TextStyle(
        fontSize: 18, fontWeight: FontWeight.w500, color: Color(0x99000000)),
    floatingLabelStyle: TextStyle(color: Color(0xFF99A8F1)),
    counterStyle: TextStyle(fontSize: 0),
    // 颜色填充
    filled: true,
    fillColor: Colors.white, // 背景色
    prefixIconColor: Color(0x99000000),
    // 边框与状态
    border: OutlineInputBorder(
        borderRadius: BorderRadius.circular(6),
        borderSide: kIsWeb
            ? BorderSide(width: 2, color: Color(0xFF99A8F1))
            : BorderSide.none),
    enabledBorder: OutlineInputBorder(
      borderRadius: BorderRadius.circular(6),
      borderSide: kIsWeb
          ? BorderSide(width: 2, color: Color(0xFFF5F5F5))
          : BorderSide.none,
    ),
    focusedBorder: OutlineInputBorder(
      borderRadius: BorderRadius.circular(6),
      borderSide: kIsWeb
          ? BorderSide(color: Color(0xFF99A8F1), width: 2)
          : BorderSide.none,
    ),
    // 其他参数
    contentPadding: EdgeInsets.symmetric(vertical: 16, horizontal: 20),
  ),
  // 设置光标颜色
  textSelectionTheme: TextSelectionThemeData(
    cursorColor: Color(0xFF99A8F1), // 光标颜色
    selectionColor: Color(0xFF99A8F1),
    selectionHandleColor: Color(0xFF99A8F1),
  ),
  // 主要按钮
  elevatedButtonTheme: ElevatedButtonThemeData(
    style: ButtonStyle(
      textStyle: WidgetStateProperty.all(
        TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),
      ),
      backgroundColor: WidgetStateProperty.resolveWith<Color>((states) {
        if (states.contains(WidgetState.disabled)) {
          return Color(0xFFABAFF5).withValues(alpha: .6); // 禁用时
        }
        return Color(0xFFABAFF5); // 默认颜色
      }),
      foregroundColor: WidgetStateProperty.all(Colors.white),
      shadowColor: WidgetStateProperty.all(Colors.black.withValues(alpha: 0.4)),
      surfaceTintColor: WidgetStateProperty.all(Colors.blue[700]),
      elevation: WidgetStateProperty.all(8.0),
      // 内边距
      padding: WidgetStateProperty.all(kIsWeb
          ? EdgeInsets.symmetric(horizontal: 20.0, vertical: 14.0)
          : EdgeInsets.symmetric(horizontal: 20.0, vertical: 12.0)),
      shape: WidgetStateProperty.all(RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(8.0),
      )),
    ),
  ),
  // 文字按钮
  textButtonTheme: TextButtonThemeData(
    style: TextButton.styleFrom(
      foregroundColor: Color(0xFF5A6A91),
      padding: EdgeInsets.symmetric(vertical: 16),
      textStyle: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.zero),
    ),
  ),

  // 分割线
  dividerTheme: DividerThemeData(
    color: const Color.fromARGB(255, 237, 237, 237),
    thickness: 1,
  ),

  // 单选框
  checkboxTheme: CheckboxThemeData(
    // ===== 核心状态处理 =====
    fillColor: WidgetStateProperty.resolveWith<Color?>(
      (Set<WidgetState> states) {
        if (states.contains(WidgetState.selected)) {
          return Color(0xFF99A8F1); // 选中时的填充色
        }
        return Colors.transparent; // 未选中透明
      },
    ),
    // ===== 动态边框系统 =====
    side: WidgetStateBorderSide.resolveWith((states) => BorderSide(
        color: states.contains(WidgetState.selected)
            ? Color(0xFF99A8F1) // 选中边框色
            : Colors.grey[600]!,
        width: 20)),
    shape: const RoundedRectangleBorder(
      borderRadius: BorderRadius.all(Radius.circular(50)), // 微圆角（Material 3 规范）
    ),
    // ===== 视觉样式 =====
    checkColor: WidgetStateProperty.all(Colors.white),
    materialTapTargetSize: MaterialTapTargetSize.padded, // 符合无障碍标准
  ),
  pageTransitionsTheme: PageTransitionsTheme(
    builders: {
      TargetPlatform.android: CupertinoPageTransitionsBuilder(),
    },
  ),
);
